home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / hoover.lua < prev    next >
Text File  |  2004-01-29  |  1KB  |  49 lines

  1. -- hoover state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onMsg("buildMenu", function(msg)
  6.     
  7.         if (repairMenu()) then return end
  8.     
  9.         -- build the pie menu
  10.         clearPieMenu();
  11.         local button;
  12.         button = addPieMenuButton("pm_cleanFloor", "cleanFloor");
  13.         button.addDescription(ACTIVITY, "cleanFloor");        
  14.         button.addDescription(ACTIVITY, "improveFloorTidiness");        
  15.         button.addIcon("guiIconWohnung");
  16.     end )
  17.  
  18.     -- 
  19.     onMsg("cleanFloor", function(msg)
  20.         -- get the game object server
  21.         local gameObjectServer = getGameObjectServer();
  22.         -- get character who initiated this action
  23.         local character = getStateObjectFromID(msg.sender);
  24.         -- get the walk state object
  25.         local wso = character.walkSO;
  26.         
  27.         local holds, hand = holdsObject(character, "hoover")
  28.         if (holds) then
  29.             wso.queueStateMachine("cleanFloorChar.findDirt", this);
  30.         else
  31.             -- walk to the closest action point
  32.             local actionPoint = character.getFreeActionPoint(this, "take");
  33.             if (actionPoint) then
  34.                 if (wso.walkToActionPoint(actionPoint)) then
  35.                     wso.queueStateMachine("cleanFloorChar.takeHoover", this);
  36.                 else
  37.                     print("no path found");
  38.                     instantAbort(character, EMOTICON_NOPATH, "emoThink")
  39.                 end
  40.             else
  41.                 print("no action point found");
  42.                 instantAbort(character, EMOTICON_CANNOT, "emoThink")
  43.             end
  44.         end
  45.     end )
  46.             
  47.             
  48. endStateMachine()
  49.